package com.demo.mq;

import org.apache.rocketmq.client.consumer.DefaultLitePullConsumer;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author shanchong
 * @date 2021/8/11
 **/
@Service
public class ConsumerDemo {

    @Autowired
    private DefaultLitePullConsumer defaultLitePullConsumer;

    public void get() {
        while (true) {
            List<MessageExt> list = defaultLitePullConsumer.poll();
            System.out.println(list);
        }
    }

}
